<p class="title">
    <%= 'Upload file'.t %>
    <img alt="spinner" id="spinner" src="/images/spinner_mac.gif" style="display:none;" />
</p>

<div id="error" style="display:none;"></div>

<% @upid = Time.now.to_i.to_s %>
<% form_tag({:action => 'do_the_upload', :upload_id => @upid, :folder_id => controller.folder_id}, {:multipart => true, :target => 'upload', :onsubmit => "UploadProgress.monitor('#{escape_javascript @upid}')"}) do %>
    <p><%= file_field 'myfile', 'myfile', :onchange => "checkFile();" %><br />
    <%= ('Max upload file size (in Kb):'.t) + (MAX_UPLOAD_FILE_SIZE / 1024).floor.to_s if MAX_UPLOAD_FILE_SIZE %></p>
    <p><%= submit_tag :Upload, :id => 'submit_upload', :disabled => true %></p>
<% end %>

<div id="results"></div>
<div id="progress-bar"><span id="initial-status">0%</span></div>

<%= link_to 'Back'.t, :controller => 'folder', :action => 'list', :id => controller.folder_id %>

<script type="text/javascript">
    function checkFile()
    {
        new Ajax.Updater('error',
                         '/file/validate_filename/<%= controller.folder_id %>', 
                         { asynchronous:true,
                           evalScripts:true,
                           onLoading:function(request){Element.show('spinner');},
                           parameters:document.getElementById('myfile_myfile').value }
            );
    }
</script>

<iframe id="upload" name="upload" src="about:blank" style="width:0px;height:0px;border-style:none;background-color:#FFF;"></iframe>